package cn.edu.scau.cmi.wuzhenxin.comprehension.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class ScauCmiHibernateSessionFactoryUtil {
	private static SessionFactory sessionFactory;
	
//sessionFactory单例模式
	public static SessionFactory getSessionFactory() {
		if(sessionFactory == null) {
			sessionFactory = new Configuration().configure("comprehensionHibernate.cfg.xml").buildSessionFactory();
		}
		return sessionFactory;
	}
	
	public static Session getSession() {
		Session session = getSessionFactory().openSession();
		return session;
	}
}
